Blitz Implementation
The source below is a include i wrote some time ago. It makes the whole
thing much easier, because you do not have to fill in huge taglists etc.
Please do not forget to insert amigalibs.res in your resident-list.
Note that this source is not runnable, because it only contains some
functions/statements to use the asl.library
Description
- succ = DTLocaleOpen{name.s}
This function tries to open the catalog 'name.s'.
The locale.library itself tries to find the catalog
for the preffered language (set in the locale-preference)
If everything was fine succ=TRUE otherwise succ=FALSE.
DTLocaleOpen{} fails if the locale.library V38 couldn't
be opened or there is no catalog in users's preffered
language. Build-in strings will be used instead.
- txt$ = DTLocaleGetStr{nr,builtin.s}
This function returns the locale-string with the ID 'nr' from the requested
catalog. If DTLocaleOpen{} failed or there is no catalog in preferred language
or there is no string ID 'nr' it returns the given value 'builtin'
- DTLocaleClose{}
This statement closes the opened catalog.
NOTE: Do not forget to close a catalog when leaving.
(it makes no difference if or why DTLocaleOpen{} failed)
Sourcecode
;===================================================================
;
; DTLocaleLib
;
; $VER = 1.0 (17.02.1996 19:24)
;
; by Peter 'dreamy' Traskalik
; dream technologies inc.
;
; succ = DTLocaleOpen{name.s} false -> using built in strings
; txt$ = DTLocaleGetStr{nr,builtin} gives the string
; DTLocaleClose{} do not forget !
;
; requires the to be resident
;
;===================================================================
DEFTYPE.Catalog DTLcat
DEFTYPE.Library DTLlib
Dim DTLtags.TagItem(4)
DTLtags(0)\ti_Tag = #OC_Language
DTLtags(0)\ti_Data = 0 ; wanted language
DTLtags(1)\ti_Tag = #OC_Version
DTLtags(1)\ti_Data = 0 ; required version
DTLtags(2)\ti_Tag = #OC_BuiltInLanguage
DTLtags(2)\ti_Data = 0 ; built in english
DTLtags(3)\ti_Tag = #OC_BuiltInCodeSet
DTLtags(3)\ti_Data = 0 ; always 0
DTLtags(4)\ti_Tag=$00000000 ;TAG_DONE
DTLtags(4)\ti_Data=0
;-------------------------------------------------------------------
Function.b DTLocaleOpen{f$}
SHARED *DTLcat,*DTLlib,DTLtags()
localelibname.s="locale.library"
*DTLlib=OpenLibrary_(&localelibname,38)
succ=False
If *DTLlib<>0
*DTLcat=OpenCatalogA_(0,&f$,&DTLtags(0))
If *DTLcat<>0 Then succ=True
EndIf
Function Return succ
End Function
;-------------------------------------------------------------------
Function.s DTLocaleGetStr{nr,def.s}
SHARED *DTLcat,*DTLlib
DEFTYPE.s tx
If *DTLcat<>0 AND *DTLlib<>0
*tx=GetCatalogStr_(*DTLcat,nr,def.s)
Function Return Peek$(*tx)
Else
Function Return def.s
EndIf
End Function
;-------------------------------------------------------------------
Statement DTLocaleClose{}
SHARED *DTLcat,*DTLlib
If *DTLcat<>0 Then CloseCatalog_(*DTLcat)
If *DTLlib<>0 Then CloseLibrary_(*DTLlib)
End Statement
;===================================================================